#include <QtGui/QApplication>
#include "fenprincipale.h"
#include "bdd.h"
#include "bddsemis.h"
#include "fichesemis.h"
#include "ficheparcelle.h"
#include "ficheculture.h"
#include "fichetraitement.h"
#include "impression.h"
#include "OngletAConfirmer.h"
#include "FicheSemisInvisible.h"
#include "XML.h"
#include "Socket.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    FenPrincipale w;
    FenPrincipale *PointeurW = &w;
    w.showMaximized();
    BDD db;

    bool Return = db.Connect();

    FicheSemis x(PointeurW);
    FicheParcelle z (PointeurW);
    FicheCulture y (PointeurW);
    FicheTraitement v (PointeurW);

    if (Return == true)
    {
        x.MettreParcelle();
        x.MettreDate();
        x.MettreSemaine();

        z.MettreParcelle();
        z.MettreDuParcelle();
        z.MettreAuParcelle();

        y.MettreParcelle();
        y.MettreCulture();
        y.MettreSemaine();
        y.MettreSurface();

        v.MettreCulture();
        v.MettreParcelle();
        v.MettreDate();
        v.MettreOperateur();
        //v.MettreSemaineSemis();
        //v.MettreSurfaceTraitee();
    }

    FicheSemisInvisible oFSI ;

    Impression oImpression(PointeurW);

    XML oXML(PointeurW );
    Socket oSocket(PointeurW, &oXML) ;

    QObject::connect(w.getBoutonOuvrir(),SIGNAL(clicked()),&x,  SLOT(BoutonOuvrirClicked()));

    QObject::connect(w.getBoutonEnregistrer(),SIGNAL(clicked()),&x,  SLOT(BoutonEnregistrerClicked()));

    QObject::connect(w.getParcelleSemis(),SIGNAL(currentIndexChanged(int)),&x,  SLOT(ValeurComboBoxChanged()));

    QObject::connect(w.getDateSemis(),SIGNAL(currentIndexChanged(int)),&x,  SLOT(ValeurComboBoxDateChanged()));

    QObject::connect(w.getBoutonOuvrirParcelle(),SIGNAL(clicked()),&z,SLOT(BoutonOuvrirClickedParcelle()));

    QObject::connect(w.getBoutonEnregistrerParcelle(),SIGNAL(clicked()),&z,SLOT(BoutonEnregistrerClickedParcelle()));

    QObject::connect(w.getComboBoxTableau(),SIGNAL(currentIndexChanged(int)),&z,SLOT(ValeurComboBoxDuChanged()));

    QObject::connect(w.getBoutonOuvrirCulture(),SIGNAL(clicked()),&y,SLOT(BoutonOuvrirClickedCulture()));

    QObject::connect(w.getComboBoxParcelleCulture(),SIGNAL(currentIndexChanged(int)),&y,SLOT(ValeurComboBoxParcelleChanged()));

    QObject::connect(w.getBoutonPrint(),SIGNAL(clicked()),&oImpression,SLOT(PrintSemis()));

    QObject::connect(w.getBoutonImpressionParcelle(),SIGNAL(clicked()),&oImpression,SLOT(printParcelle()));

    QObject::connect(w.getBoutonBDD(),SIGNAL(clicked()),&db,SLOT(ConnectSlot()));

    QObject::connect(w.getBoutonOuvrirTraitement(),SIGNAL(clicked()),&v,SLOT(BoutonOuvrirClickedTraitement()));


    return a.exec();
}
